package cc.chinagps.gateway.unit.eg.util;

import cc.chinagps.gateway.unit.UnitSocketSession;
import cc.chinagps.gateway.unit.eg.define.EGDefines;

public class EGPkgUtil {
	public static short getSn(UnitSocketSession unitSession){
		synchronized (unitSession) {
			Object obj = unitSession.getAttribute(EGDefines.EG_SESSION_KEY_SN);
			Short v;
			if(obj == null){
				v = 1;
			}else{
				v = (Short) obj;
				v++;
			}
			
			unitSession.setAttribute(EGDefines.EG_SESSION_KEY_SN, v);
			return v;
		}
	}
	
	public static String getCmdCacheSn(String callLetter, int cmdId){
		return callLetter + "_" + cmdId;
	}
	
	public static String getCmdCacheSn(String callLetter, short serialNo){
		return callLetter + "_" + serialNo;
	}


}
